package strategy;

/**
 * 支付策略模式演示类
 */
public class PaymentDemo {
    public static void main(String[] args) {
        // 创建支付上下文，初始使用现金支付
        PaymentContext context = new PaymentContext(new CashPayment());
        
        // 使用现金支付
        System.out.println("===== 使用现金支付 =====");
        context.executePayment(100.0);
        
        // 切换到信用卡支付
        System.out.println("\n===== 切换到信用卡支付 =====");
        context.setStrategy(new CreditCardPayment("1234-5678-9012-3456", "12/25", "123"));
        context.executePayment(200.0);
        
        // 切换到支付宝支付
        System.out.println("\n===== 切换到支付宝支付 =====");
        context.setStrategy(new AlipayPayment("alipay@example.com"));
        context.executePayment(300.0);
    }
}